Learn R Programming

Rfast (version 1.5)

Lower triangular of a (square) matrix: Lower triangular of a (square) matrix or upper triangular of a (square) matrix

Description

Lower triangular of a (square) matrix. Upper triangular of a (square) matrix

Usage

lower_tri(x,value) upper_tri(x,value)

Arguments

x
A matrix.
value
A logical value for choosing to return the values of the lower triangular and note a logical matrix.

Value

A logical matrix TRUE in the position of the triangular matrix or a vector with the lower triangular elements of a matrix .

Details

The algorithm is written in C++ to speed up things.

See Also

sort_mat

Examples

Run this code
x <- matrix(rnorm(500 * 500), ncol = 500)
system.time( for (i in 1:100) lower_tri(x) )
system.time( for (i in 1:100) lower_tri(x,TRUE) )
system.time( for (i in 1:100) upper_tri(x) )
system.time( for (i in 1:100) upper_tri(x,TRUE) )

Run the code above in your browser using DataLab